#[test]
fn test_bulb_switch() {
    // for n in 1..20 {
    //     println!("n={} -> {}, n.sqrt()={}", n, bulb_switch(n), (n as f64).sqrt() as i32);
    // }
    println!("sqrt(99999999 as f32)={}, sqrt(99999999 as f64)={}", (99999999 as f32).sqrt(), (99999999 as f64).sqrt())
}

// 319，比自己小的因数的个数
// 完全平方数的个数
fn bulb_switch(n: i32) -> i32 {
    let mut ans = 0;
    for i in 1..=n {
        let mut factor_count = 0;
        for j in 1..i {
            if i % j == 0 {
                factor_count += 1;
            }
        }
        ans += factor_count % 2
    }
    n - ans
}

// 326
#[test]
fn test_power_of_three() {
    for i in 1..10 {
        println!("3^{} = {}", i, 3_i32.pow(i));
    }
    let n = 3;
    // 3的幂次方的质因子只有 '3'
    println!("{}", n > 0 && 3_i32.pow(20) % n == 0);
}